#include <iostream>
#include <unordered_map>

using namespace std;

typedef long long LL;
const int N = 2e5 + 10;

//A = B + C
//1.统计出数组中每个数出现的次数
//2.枚举所有的B，然后找出C+B出现的次数

LL n, c; 
int a[N];
unordered_map<int, int> mp; // 数，该数出现的次数

int main()
{
	cin >> n >> c;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		mp[a[i]]++;
	}

	LL cnt = 0;
	for(int i = 1; i <= n; i++)
	{
		// b = a[i]
		// 找 c + a[i]
		cnt += mp[a[i] + c];
	}
	cout << cnt << endl;

	return 0;
}


